{% extends 'base.html' %}

{% block title %}{{ title }} - 教务信息管理系统{% endblock %}

{% block content %}
<div class="row">
    <div class="col-12">
        <div class="d-flex justify-content-between align-items-center mb-4">
            <h2>
                <i class="fas fa-user-circle me-2 text-primary"></i>
                {{ title }}
            </h2>
            <a href="{% url 'accounts:profile_edit' %}" class="btn btn-primary">
                <i class="fas fa-edit me-1"></i>编辑信息
            </a>
        </div>
    </div>
</div>

<div class="row">
    <div class="col-lg-8 col-md-10 mx-auto">
        <div class="card shadow">
            <div class="card-header bg-primary text-white">
                <h5 class="card-title mb-0">
                    <i class="fas fa-id-card me-2"></i>
                    个人信息
                </h5>
            </div>
            <div class="card-body">
                <div class="row">
                    <div class="col-md-6">
                        <div class="info-item mb-3">
                            <label class="form-label text-muted">
                                <i class="fas fa-user me-1"></i>用户名
                            </label>
                            <div class="info-value">{{ user.username }}</div>
                        </div>
                    </div>
                    
                    <div class="col-md-6">
                        <div class="info-item mb-3">
                            <label class="form-label text-muted">
                                <i class="fas fa-id-card me-1"></i>姓名
                            </label>
                            <div class="info-value">{{ user.first_name|default:"未设置" }}</div>
                        </div>
                    </div>
                </div>
                
                <div class="row">
                    <div class="col-md-6">
                        <div class="info-item mb-3">
                            <label class="form-label text-muted">
                                <i class="fas fa-envelope me-1"></i>邮箱
                            </label>
                            <div class="info-value">{{ user.email|default:"未设置" }}</div>
                        </div>
                    </div>
                    
                    <div class="col-md-6">
                        <div class="info-item mb-3">
                            <label class="form-label text-muted">
                                <i class="fas fa-user-tag me-1"></i>角色
                            </label>
                            <div class="info-value">
                                <span class="badge bg-{% if user_profile.is_admin %}primary{% else %}info{% endif %} fs-6">
                                    {{ user_profile.get_role_display }}
                                </span>
                            </div>
                        </div>
                    </div>
                </div>
                
                {% if user_profile.college_name %}
                <div class="row">
                    <div class="col-md-6">
                        <div class="info-item mb-3">
                            <label class="form-label text-muted">
                                <i class="fas fa-university me-1"></i>学院名称
                            </label>
                            <div class="info-value">{{ user_profile.college_name }}</div>
                        </div>
                    </div>
                </div>
                {% endif %}
                
                <div class="row">
                    <div class="col-md-6">
                        <div class="info-item mb-3">
                            <label class="form-label text-muted">
                                <i class="fas fa-calendar-alt me-1"></i>注册时间
                            </label>
                            <div class="info-value">{{ user.date_joined|date:"Y年m月d日 H:i" }}</div>
                        </div>
                    </div>
                    
                    <div class="col-md-6">
                        <div class="info-item mb-3">
                            <label class="form-label text-muted">
                                <i class="fas fa-clock me-1"></i>最后登录
                            </label>
                            <div class="info-value">
                                {% if user.last_login %}
                                    {{ user.last_login|date:"Y年m月d日 H:i" }}
                                {% else %}
                                    从未登录
                                {% endif %}
                            </div>
                        </div>
                    </div>
                </div>
                
                <div class="row">
                    <div class="col-md-6">
                        <div class="info-item mb-3">
                            <label class="form-label text-muted">
                                <i class="fas fa-toggle-on me-1"></i>账号状态
                            </label>
                            <div class="info-value">
                                {% if user.is_active %}
                                    <span class="badge bg-success fs-6">激活</span>
                                {% else %}
                                    <span class="badge bg-secondary fs-6">禁用</span>
                                {% endif %}
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        
        <!-- 统计信息卡片 -->
        {% if not user_profile.is_admin %}
        <div class="card shadow mt-4">
            <div class="card-header bg-info text-white">
                <h5 class="card-title mb-0">
                    <i class="fas fa-chart-bar me-2"></i>
                    我的统计
                </h5>
            </div>
            <div class="card-body">
                <div class="row text-center">
                    <div class="col-md-4">
                        <div class="stat-item">
                            <div class="stat-number text-primary">{{ my_subprojects_count|default:0 }}</div>
                            <div class="stat-label text-muted">创建的子项目</div>
                        </div>
                    </div>
                    <div class="col-md-4">
                        <div class="stat-item">
                            <div class="stat-number text-success">{{ my_completed_subprojects|default:0 }}</div>
                            <div class="stat-label text-muted">已完成项目</div>
                        </div>
                    </div>
                    <div class="col-md-4">
                        <div class="stat-item">
                            <div class="stat-number text-info">
                                {% widthratio my_completed_subprojects my_subprojects_count 100 %}%
                            </div>
                            <div class="stat-label text-muted">完成率</div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        {% endif %}
    </div>
</div>

<style>
.info-item {
    border-bottom: 1px solid #eee;
    padding-bottom: 0.5rem;
}

.info-item:last-child {
    border-bottom: none;
}

.info-value {
    font-size: 1.1rem;
    font-weight: 500;
    color: #333;
}

.stat-item {
    padding: 1rem;
}

.stat-number {
    font-size: 2rem;
    font-weight: bold;
    margin-bottom: 0.5rem;
}

.stat-label {
    font-size: 0.9rem;
}
</style>
{% endblock %}